package com.japp.manager.web;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.japp.base.BaseAction;
import com.japp.manager.bean.RealityQtargetBean;
import com.japp.manager.service.RealityQtargetService;
import com.japp.sys.bean.SelectBean;
import com.japp.sys.mapper.DpMapper;
import com.japp.tools.common.Common;
import com.japp.tools.common.JappLog;

@Scope("prototype")
@Controller
public class RealityQtargetAction extends BaseAction<RealityQtargetBean> {
	private static final long serialVersionUID = -5677670163048708849L;
	@Autowired
	private RealityQtargetService realityQtargetService;
	@Autowired
	private DpMapper dpMapper;
	private RealityQtargetBean q = new RealityQtargetBean();
	private Map<String, Object> map;
	private String selectedIdx = "0";
	/**
	 * 经营数据管理
	 * @return
	 */
	public String findRealityQ(){
		//r.setEi_date_type("1");
		//r.setEi_date("2013-06-16");
		String power = q.getQ_power();
		String u_power = String.valueOf(session.getAttribute("u_power"));
		if(power==null||"".equals(power)){
			if(u_power!=null&&!"".equals(u_power)){
				q.setQ_power(("0".equals(u_power)?"1":u_power));
				if("2".equals(u_power)){
					q.setQ_dpid(session.getAttribute("userltd").toString());
				}else if("3".equals(u_power)){
					q.setQ_ucode(String.valueOf(session.getAttribute("u_code")));
				}
			}
		}
		try {
			List<SelectBean> list = dpMapper.queryDpSelectAll(); // 部门
			json_val = Common.formtSelectToJson(list);
		} catch (Exception e) {
			JappLog.log.error("查询部门或转换Json错误", e);
		}
		map = realityQtargetService.findRealityQ(q);
		return SUCCESS;
	}
	public RealityQtargetBean getQ() {
		return q;
	}
	public void setQ(RealityQtargetBean q) {
		this.q = q;
	}
	public Map<String, Object> getMap() {
		return map;
	}
	public void setMap(Map<String, Object> map) {
		this.map = map;
	}
	public String getSelectedIdx() {
		return selectedIdx;
	}
	public void setSelectedIdx(String selectedIdx) {
		this.selectedIdx = selectedIdx;
	}
}
